package cn.com.lyb.workflow.controller;


import cn.com.lyb.core.response.ResultDTO;
import cn.com.lyb.workflow.entity.dto.SaveWorkflowDTO;
import cn.com.lyb.workflow.service.IWorkflowService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 工作流 前端控制器
 * </p>
 *
 * @author lvyuanbo
 * @since 2024-07-19
 */
@RestController
@RequestMapping("/workflowDO")
public class WorkflowController {

    @Autowired
    private IWorkflowService workflowService;

    @ApiOperation(value = "运行工作流")
    @ApiImplicitParam(name = "workflowId", value = "workflowId", required = true)
    @PostMapping("/start")
    public ResultDTO startWorkflow(Long workflowId) {
        workflowService.startWorkflow(workflowId);
        return ResultDTO.success();
    }

//    @ApiOperation(value = "暂停工作流")
//    @ApiImplicitParam(name = "workflowInstanceId", value = "workflowInstanceId", required = true)
//    @PostMapping("/pause")
//    public ResultDTO pauseWorkflow(Long workflowInstanceId) {
//        workflowService.pauseWorkflow(workflowInstanceId);
//        return ResultDTO.success();
//    }
//
//    @ApiOperation(value = "恢复运行工作流")
//    @ApiImplicitParam(name = "workflowInstanceId", value = "workflowInstanceId", required = true)
//    @PostMapping("/resume")
//    public ResultDTO resumeWorkflow(Long workflowInstanceId) {
//        workflowService.resumeWorkflow(workflowInstanceId);
//        return ResultDTO.success();
//    }

    @ApiOperation(value = "保存工作流")
    @PostMapping("/saveEntity")
    public ResultDTO resumeWorkflow(@RequestBody SaveWorkflowDTO saveWorkflowDTO) {
        workflowService.saveEntity(saveWorkflowDTO);
        return ResultDTO.success();
    }

}
